import React, { PureComponent } from "react";
import { connect } from "react-redux";
import { setDataList } from "../store/modules/banner/actionCreators";

class Request extends PureComponent {
  componentDidMount() {
    this.props.getDataList();
  }

  render() {
    return (
      <div>
        Request
        <ul>
          {this.props.dataList.map(v => (
            <li key={v.id}>{v.imgUrl}</li>
          ))}
        </ul>
      </div>
    );
  }
}

const mapStateToProps = state => {
  return {
    dataList: state.banner.dataList,
  };
};

const mapDispatchToProps = dispatch => {
  return {
    getDataList() {
      dispatch(setDataList());
    },
  };
};

export default connect(mapStateToProps, mapDispatchToProps)(Request);
